<script type="text/html" template>
    <link rel="stylesheet" href="{{ layui.setter.base }}style/alert.css">
</script>
<style scoped>
    .row .layui-input {
        flex-grow: 1;
        width: inherit;
        height: inherit;
    }

    .title-btn {
        display: flex;
        display: -webkit-flex;
        justify-content: flex-start;
        margin-top: 23px;
        margin-bottom: 5px;
        flex-flow: row wrap;
    }

    .row .layui-form-label {
        float: none;
        padding: 0;
        text-align: left;
        font-size: 12px;
        color: #616161;
        width: 200px;
        white-space: nowrap;
    }


    .row .layui-form-item {
        display: flex;
        display: -webkit-flex;
        justify-content: flex-start;
        flex-flow: row nowrap;
        height: auto;
        margin: 0;

    }

    .row li {
        text-align: left;
        display: flex;
        display: -webkit-flex;
        justify-content: flex-start;
        flex-flow: row wrap;
        padding-left: 22px;
    }

    .row .layui-form-select .layui-input {
        padding-right: 0;
    }

    .row .layui-input-block {
        margin: 0;
    }

    #title-name {
        font-size: 15px;
    }

    .row .layui-form-label {
        width: 100px;
        text-align: right;
    }
</style>


<div class="layui-form" lay-filter="layuiadmin-form-tags" id="layuiadmin-form-tags">
    <ul class="layui-row layui-form row">
        <li class="layui-col-xs4 layui-col-sm4 layui-col-md4">
            <div class="flex layui-form-item">
                <label class="layui-form-label"> 设备编号：</label>
                <div class="layui-input-block">
                    <input type="text" name="fia01" readonly id="fia01" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="flex layui-form-item">
                <label class="layui-form-label"> 设备类型：</label>
                <div class="layui-input-block">
                    <input type="text" name="fic02" readonly id="fic02" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="flex layui-form-item">
                <label class="layui-form-label"> 设备系列：</label>
                <div class="layui-input-block">
                    <input type="text" name="tcSeriesName" readonly id="tcSeriesName" autocomplete="off"
                        class="layui-input">
                </div>
            </div>
            <div class="flex layui-form-item">
                <label class="layui-form-label"> 原资产编号：</label>
                <div class="layui-input-block">
                    <input type="text" name="fia011" readonly id="fia011" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="flex layui-form-item">
                <label class="layui-form-label"> 原所在厂房：</label>
                <div class="layui-input-block">
                    <input type="text" name="tcFtyName" readonly id="tcFtyName" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="flex layui-form-item">
                <label class="layui-form-label"> 原站别：</label>
                <div class="layui-input-block">
                    <input type="text" name="tcProcName" readonly id="tcProcName" autocomplete="off"
                        class="layui-input">
                </div>
            </div>
            <div class="flex layui-form-item">
                <label class="layui-form-label">原线别：</label>
                <div class="layui-input-block">
                    <input type="text" name="tcLineName" readonly id="tcLineName" autocomplete="off"
                        class="layui-input">
                </div>
            </div>
            <div class="flex layui-form-item">
                <label class="layui-form-label"> 原负责人：</label>
                <div class="layui-input-block">
                    <input type="text" name="keeper" readonly id="keeper" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="flex layui-form-item">
                <label class="layui-form-label"> 原所在楼层：</label>
                <div class="layui-input-block">
                    <input type="text" name="tcFlrName" readonly id="tcFlrName" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="flex layui-form-item">
                <label class="layui-form-label"> 原负责部门：</label>
                <div class="layui-input-block">
                    <input type="text" name="gem02" readonly id="gem02" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="flex layui-form-item">
                <label class="layui-form-label"> 原设备调机人员：</label>
                <div class="layui-input-block">
                    <input type="text" name="fiauser" readonly id="fiauser" autocomplete="off" class="layui-input">
                </div>
            </div>


        </li>
        <li class="layui-col-xs4 layui-col-sm4 layui-col-md4" style="margin-left: 70px;">

            <div class="flex layui-form-item">
                <label class="layui-form-label"><span
                        style="font-size: 18px;color: red;position: relative;display: inline-block;line-height: 20px;vertical-align: middle;top:3px;">*</span>新负责部门：</label>
                <div class="layui-input-block">

                    <input type="text" id="treeSelect" name="tcDetailFia11" autocomplete="off" class="layui-input "
                        lay-verify="required">

                </div>
            </div>
            <div class="flex layui-form-item">
                <label class="layui-form-label"> <span
                        style="font-size: 18px;color: red;position: relative;display: inline-block;line-height: 20px;vertical-align: middle;top:3px;">*</span>新资产编号：</label>
                <div class="layui-input-block">
                    <input type="text" name="tcDetailFia011" id="tcDetailFia011" autocomplete="off" class="layui-input"
                        lay-verify="required">
                </div>
            </div>
            <div class="flex layui-form-item">
                <label class="layui-form-label"> <span
                        style="font-size: 18px;color: red;position: relative;display: inline-block;line-height: 20px;vertical-align: middle;top:3px;">*</span>新所在厂房：</label>
                <div class="layui-input-block">
                    <select id="tcDetailFia14" name="tcDetailFia14" lay-filter="selectTemplate" lay-search
                        lay-verify="required">

                    </select>
                </div>
            </div>
            <div class="flex layui-form-item">
                <label class="layui-form-label"><span
                        style="font-size: 18px;color: red;position: relative;display: inline-block;line-height: 20px;vertical-align: middle;top:3px;">*</span>
                    新所在楼层：</label>
                <div class="layui-input-block">
                    <select id="tcDetailFia15" name="tcDetailFia15" lay-search lay-verify="required">

                    </select>

                </div>
            </div>

            <div class="flex layui-form-item">
                <label class="layui-form-label"><span
                        style="font-size: 18px;color: red;position: relative;display: inline-block;line-height: 20px;vertical-align: middle;top:3px;">*</span>新站别：</label>
                <div class="layui-input-block">

                    <select id="tcDetailFia16" name="tcDetailFia16" lay-search lay-verify="required">

                    </select>

                </div>
            </div>
            <div class="flex layui-form-item">
                <label class="layui-form-label"><span
                        style="font-size: 18px;color: red;position: relative;display: inline-block;line-height: 20px;vertical-align: middle;top:3px;">*</span>新线别：</label>
                <div class="layui-input-block">
                    <select id="tcDetailFia17" name="tcDetailFia17" lay-search lay-verify="required">

                    </select>

                </div>
            </div>
            <div class="flex layui-form-item">
                <label class="layui-form-label"><span
                        style="font-size: 18px;color: red;position: relative;display: inline-block;line-height: 20px;vertical-align: middle;top:3px;">*</span>新负责人：</label>
                <div class="layui-input-block">
                    <select id="tcDetailFia10" name="tcDetailFia10" lay-search lay-verify="required">

                    </select>

                </div>
            </div>


            <div class="flex layui-form-item">
                <label class="layui-form-label"><span
                        style="font-size: 18px;color: red;position: relative;display: inline-block;line-height: 20px;vertical-align: middle;top:3px;">*</span>新设备调机人员：</label>
                <div class="layui-input-block">
                    <select id="tcDetailFiauser" name="tcDetailFiauser" lay-search lay-verify="required">

                    </select>

                </div>
            </div>
            <div class="flex layui-form-item">
                <label class="layui-form-label"> 设备名称：</label>
                <div class="layui-input-block">
                    <input type="text" name="fia02" readonly id="fia02" autocomplete="off" class="layui-input"
                        lay-verify="required">
                </div>
            </div>
            <div class="flex layui-form-item">
                <label class="layui-form-label"> 供应商：</label>
                <div class="layui-input-block">
                    <input type="text" name="pmc081" readonly id="pmc081" autocomplete="off" class="layui-input"
                        lay-verify="required">
                </div>
            </div>
            <div class="flex layui-form-item">
                <label class="layui-form-label"> 设备型号：</label>
                <div class="layui-input-block">
                    <input type="text" name="fii02" readonly id="fii02" autocomplete="off" class="layui-input"
                        lay-verify="required">
                </div>
            </div>



        </li>

    </ul>



    <div class="footer layui-btn-containner">
        <button class="commit layui-btn layui-btn-radius layui-btn-primary" lay-submit
            lay-filter="LAY-submit">确认</button>
        <button class="cancel layui-btn layui-btn-radius layui-btn-primary cancel" lay-filter="LAY-cancel">取消</button>
    </div>

</div>

<script>
    layui.use(['admin', 'form', 'api', 'table', 'laytpl', 'utill', 'laydate', 'treeSelect'], function () {
        var $ = layui.$,
            admin = layui.admin,
            view = layui.view,
            api = layui.api,
            table = layui.table,
            setter = layui.setter,
            jquery = layui.jquery,
            laydate = layui.laydate,
            form = layui.form;
            layer = layui.layer,
            util = layui.util,
            treeSelect = layui.treeSelect;
            let tcReqCoalt  = sessionStorage.getItem('company');
            var trindex = parent.trindex;
            var aa = parent.devAlt;
        $('#tcDetailFia011').val(aa.tcDetailFia011 == undefined ? "" : aa.tcDetailFia011);//新资产编号回显
        admin.req({
            url: api.host + api.selectCoaltDept,
            data: {
                tcReqCoalt: tcReqCoalt
            },
            done: function (res) {
                function transferKey(odata) {
                    odata.forEach(obj => {
                        obj.title = obj.gem02
                        obj.children = obj.deptVOS
                        obj.id = obj.gem01
                        delete obj["gem02"]
                        delete obj["deptVOS"]
                        if (obj.children instanceof Array) {
                            transferKey(obj.children)
                        }
                        if (aa.tcDetailFia11 == obj.gem01) {
                            $("#treeSelect").val(obj.title + "/" + obj.gem01)
                        }
                    })
                    return odata
                }

                odataArr = transferKey(res.data)

                treeSelect.render({
                    elem: "#treeSelect",
                    node: odataArr,
                    done: (data) => {
                        $("#treeSelect").val(data.data.title + "/" + data.data.gem01)
                    }
                })

            }
        });
        f15();
        function f15() {
            var fi14 = aa.tcDetailFia14
            if (fi14 == null || fi14 == "") {
                return;
            }
            admin.req({
                url: api.host + api.selectFtyFlr,
                data: {
                    ftyId: fi14
                },
                done: function (res) {
                    var str = '<option value=""></option>'
                    for (let index = 0; index < res.data.length; index++) {
                        if (aa.tcDetailFia15 == res.data[index].tcFlrId) {
                            str = str + `<option value="${res.data[index].tcFlrId}/${res.data[index].tcFlrName}" selected>${res.data[index].tcFlrName}</option>`
                        } else {
                            str = str + `<option value="${res.data[index].tcFlrId}/${res.data[index].tcFlrName}">${res.data[index].tcFlrName}</option>`
                        }
                    }

                    $('#tcDetailFia15').html(str)
                    form.render(null, 'layuiadmin-form-tags');
                }
            });
        }

        form.on('select(selectTemplate)', function (data) {
            var id = data.value.split("/")[0].replace(/\s+/g, "");
            admin.req({
                url: api.host + api.selectFtyFlr,

                data: {
                    ftyId: id
                },
                done: function (res) {
                    var str = '<option value=""></option>'
                    for (let index = 0; index < res.data.length; index++) {
                        if (aa.tcDetailFia15 == res.data[index].tcFlrId) {
                            str += `<option value="${res.data[index].tcFlrId}/${res.data[index].tcFlrName}" selected>${res.data[index].tcFlrName}</option>`
                        } else {
                            str = str + `<option value="${res.data[index].tcFlrId}/${res.data[index].tcFlrName}">${res.data[index].tcFlrName}</option>`
                        }
                    }

                    $('#tcDetailFia15').html(str)
                    form.render(null, 'layuiadmin-form-tags');
                }
            });
        })

        admin.req({
            url: api.host + api.selectCoaltFty,
            data: {
                tcReqCoalt: tcReqCoalt
            },
            done: function (res) {
                var str = '<option value=""></option>'
                for (let index = 0; index < res.data.length; index++) {
                    if (aa.tcDetailFia14 == res.data[index].tcFtyId) {
                        str = str + `<option value=" ${res.data[index].tcFtyId}/${res.data[index].tcFtyName}" selected>${res.data[index].tcFtyName}</option>`
                    } else {
                        str = str + `<option value=" ${res.data[index].tcFtyId}/${res.data[index].tcFtyName}">${res.data[index].tcFtyName}</option>`
                    }
                }
                $('#tcDetailFia14').append(str)
                form.render(null, 'layuiadmin-form-tags');
            }
        });


        admin.req({
            url: api.host + api.selectFiaDB,
            data: {
                fia01: sessionStorage.getItem('fia01')
            },

            done: function (res) {
                $('#fia02').val(res.data[0].fia02)
                $('#tcSeriesName').val(res.data[0].tcSeriesName)
                $('#tcProcName').val(res.data[0].tcProcName)
                $('#tcFtyName').val(res.data[0].tcFtyName)
                $('#pmc081').val(res.data[0].pmc081)
                $('#gem02').val(res.data[0].gem02)
                $('#keeper').val(res.data[0].keeper)
                $('#fic02').val(res.data[0].fic02)
                $('#fiauser').val(res.data[0].fiauser)
                $('#tcFlrName').val(res.data[0].tcFlrName)
                $('#fia011').val(res.data[0].fia011)
                $('#fia01').val(sessionStorage.getItem('fia01'))
                $('#tcLineName').val(res.data[0].tcLineName)
                $('#fii02').val(res.data[0].fii02)

            }
        });

        admin.req({
            url: api.host + api.selectFiaProcId,
            type: 'post',
            data: {
                tcReqCoalt: tcReqCoalt
            },
            done: function (res) {



                var str = '<option value=""></option>'
                for (let index = 0; index < res.data.length; index++) {
                    if (aa.tcDetailFia16 == res.data[index].tcProcId) {
                        str = str + `<option value=" ${res.data[index].tcProcId}/${res.data[index].tcProcName}" selected>${res.data[index].tcProcName}</option>`
                    } else {
                        str = str + `<option value=" ${res.data[index].tcProcId}/${res.data[index].tcProcName}">${res.data[index].tcProcName}</option>`
                    }
                }

                $('#tcDetailFia16').append(str)
                form.render(null, 'layuiadmin-form-tags');
            }
        });

        admin.req({
            url: api.host + api.selectFiaLineId,
            type: 'post',
            data: {
                tcReqCoalt: tcReqCoalt
            },
            done: function (res) {

                var str = '<option value=""></option>'
                for (let index = 0; index < res.data.length; index++) {
                    if (aa.tcDetailFia17 == res.data[index].tcLineId) {
                        str = str + `<option
                value=" ${res.data[index].tcLineId}/${res.data[index].tcLineName}" selected>${res.data[index].tcLineName}</option>`
                    } else {
                        str = str + `<option
                value=" ${res.data[index].tcLineId}/${res.data[index].tcLineName}">${res.data[index].tcLineName}</option>`

                    }

                }

                $('#tcDetailFia17').append(str)
                form.render(null, 'layuiadmin-form-tags');
            }
        });

        admin.req({
            url: api.host + api.selectKeeper,
            data: {
                tcReqCoalt: tcReqCoalt
            },
            done: function (res) {
                var str = '<option value=""></option>'
                var str1 = '<option value=""></option>'
                for (let index = 0; index < res.data.length; index++) {
                    if (aa.tcDetailFia10 == res.data[index].gen01) {
                        str = str + `<option
                    value="${res.data[index].gen01}/${res.data[index].gen02}" selected>${res.data[index].gen02}</option>`

                    } else {
                        str = str + `<option
                    value="${res.data[index].gen01}/${res.data[index].gen02}">${res.data[index].gen02}</option>`
                    }
                    if (aa.tcDetailFiauser == res.data[index].gen01) {
                        str1 = str1 + `<option
                    value="${res.data[index].gen01}/${res.data[index].gen02}" selected>${res.data[index].gen02}</option>`

                    } else {
                        str1 = str1 + `<option
                    value="${res.data[index].gen01}/${res.data[index].gen02}">${res.data[index].gen02}</option>`
                    }
                }
                $('#tcDetailFia10').append(str)
                $('#tcDetailFiauser').append(str1)
                form.render(null, 'layuiadmin-form-tags');
            }
        });
        // 表格里面的编辑取消
        $(".cancel").click(function () {
            layer.closeAll();
        });

    });
</script>